package com.wise.site.protocol.result;

import org.json.JSONException;
import org.json.JSONObject;

import com.wise.site.protocol.base.SoapItem;
import com.wise.site.protocol.base.SoapResult;
import com.wise.site.utils.Constanct;

/**
 * 店铺列表item
 * @author huangyue
 *
 */
public class ShopItem extends SoapItem {
	public int userId;
	/**
	 * 商铺id
	 */
	public int shopId;
	//商铺用户昵称
	public String nickname;
	//商铺用户头像链接
	public String portraitImageUrl;
	//商铺名称
	public String shopName;
	//商铺logo链接
	public String logoImageUrl;
	//商铺等级
	public int level = 1;
	//商铺等级名称
	public String levelNmae;
	//商铺描述
	public String description;
	//商铺地址
	public String address;
	//商铺联系电话
	public String phone;
	//商铺邮件邮址     --->email
	public String email;
	//商铺官网         --->officialWebsite
	public String officialWebsite;
	//商铺是否被推荐   --->recommended      		
	public boolean recommended;
	//商铺所属类别     --->category         	
	public String category;
	
	public double longitude;
	
	public double latitude;
	
	public String[] imageUrls;
	
	public ShopItem() {
	}
	
	public ShopItem(JSONObject node) {
		try {
			parse(node);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@Override
	public void parse(JSONObject node) throws JSONException {
		if(!node.isNull("userId")){
			userId = node.getInt("userId");
		}
		if(!node.isNull("shopId")){
			shopId = node.getInt("shopId");
		}
		if(!node.isNull("id")){
			shopId = node.getInt("id");
		}
		if(!node.isNull("nickname")){
			nickname = node.getString("nickname");
		}
		if(!node.isNull("portraitImageUrl")){
			portraitImageUrl = Constanct.IMAGE_PREFIX + node.getString("portraitImageUrl");
		}
		shopName = node.getString("name");
		logoImageUrl = Constanct.IMAGE_PREFIX + node.getString("logoImageUrl");
		if(!node.isNull("levelid")){
			level = node.getInt("levelid");
		}
		if(!node.isNull("levelname")){
			levelNmae = node.getString("levelname");
		}
		description = node.getString("description");
		address = node.getString("address");
		phone = node.getString("phone");
		if(!node.isNull("email")){
			email = node.getString("email");
		}
		if(!node.isNull("officialWebsite")){
			officialWebsite = node.getString("officialWebsite");
		}
		if(!node.isNull("recommended")){
			recommended = node.getInt("recommended") == 1;
		}
		if(!node.isNull("category")){
			category = node.getString("category");
		}
		
		if(!node.isNull("imageUrls")){
			imageUrls = node.getString("imageUrls").split(",");
		}
		
		if(!node.isNull("longitude")){
			longitude = node.getDouble("longitude");
		}
		
		if(!node.isNull("latitude")){
			latitude = node.getDouble("latitude");
		}
	}
	
	
	


}
